<!DOCTYPE html>
<html>
<head>
</head>
<body>
<form action="user.php" method="post" enctype="multipart/form-data">
    请选择商品图片
    <input type="file"  name="file" id="file" multiple="multiple" onchange="showImg()">
    <br />
    <img src="" id="showImg">
    <input type="submit" id="" value="提交" />
</form>
<!--    <button onclick="showImg();">显示图片</button>-->
</body>


<script type="text/javascript">
    var fileObj = document.getElementById('file');
    function showImg(){
        var files = fileObj['files'];
        var URL = window.URL || window.webkitURL;
        var imgURL = URL.createObjectURL(files[0]);
        document.getElementById('showImg').src = imgURL;
    }
</script>
</html>